package util;

import com.rabbitmq.client.ConnectionFactory;
import helloword.Send;

import java.util.Properties;

/**
 * 描述：TODO
 */

public class Tools {
    static public ConnectionFactory getFactory() throws Exception {
        // 加载配置文件
        Properties properties = new Properties();
        properties.load(Send.class.getClassLoader().getResourceAsStream("application.properties"));
        // 创建连接工厂
        ConnectionFactory factory = new ConnectionFactory();
        // 设置RabbitMQ地址
        factory.setHost(properties.getProperty("rabbitmq.host"));
        factory.setUsername(properties.getProperty("rabbitmq.username"));
        factory.setPassword(properties.getProperty("rabbitmq.password"));
        return factory;
    }
}
